import express, { Router } from 'express';
import { auth } from '../middleware/auth';
import { asyncHandler } from '../middleware/asyncHandler';
import {
  createReport,
  updateReport,
  deleteReport,
  getReports,
  getReportById,
  generateReport,
  getReportStatus,
  getReportFile
} from '../controllers/reportController';

const router: Router = express.Router();

// 创建报表
router.post('/', auth, asyncHandler(createReport));

// 更新报表
router.put('/:reportId', auth, asyncHandler(updateReport));

// 删除报表
router.delete('/:reportId', auth, asyncHandler(deleteReport));

// 获取报表列表
router.get('/', auth, asyncHandler(getReports));

// 获取报表详情
router.get('/:reportId', auth, asyncHandler(getReportById));

// 生成报表
router.post('/:reportId/generate', auth, asyncHandler(generateReport));

// 获取报表状态
router.get('/:reportId/status', auth, asyncHandler(getReportStatus));

// 获取报表文件
router.get('/:reportId/export/:historyId', auth, asyncHandler(getReportFile));

export default router;
